import QtQuick 2.0
import QtQuick.Controls 1.1

Rectangle{
    width: 480; height: 320
    color: "#121212"
    BusyIndicator{
        id: busy
        running: true
        anchors.centerIn: parent
        z: 2
    }
    Text {
        id: stateLable
        visible: false
        anchors.centerIn: parent
        z: 3
    }

    Image {
        id: imageView
        asynchronous: true
        cache: false
        anchors.fill: parent
        fillMode: Image.PreserveAspectFit
        onStatusChanged: {
            if (imageView.status == Image.Loading){
                busy.running = true;
                stateLable.visible = false;
            }else if (imageView.status == Image.Ready){
                busy.running = false;
            }else if (imageView.status == Image.Error){
                busy.running = false;
                stateLable.visible = true;
                stateLable.text = "ERROR";
            }
        }
    }

    Component.onCompleted: {
        imageView.source = "http://b.hiphotos.baidu.com/image/w%3D2048/sign=12a6698234d12f2ece05a9607bfad462/d009b3de9c82d158a5f551e4820a19d8bc3e426b.jpg"
    }
}
